import http from "./http"

const getAllDepartment = ()=>{
    const path = "/staff/departments/"
    return http.get(path)
}

const addsStaff =(realname,email,password) =>{
    const path = "/staff/"
    return http.post(path,{realname,email,password})
}

const getStaffList =(page=1,size=10,params) =>{
    const path = `/staff/`
    params = params ? params : {}
    params['page'] = page
    params['size'] = size

    return http.get(path,params)
}

const updateStaffStatus = (staff_id,status) =>{
    const path = "/staff/" + staff_id
    return http.put(path,{status})

}

const downloadStaffs =(pks) =>{
    const query = encodeURIComponent(JSON.stringify(pks))
    const path = `/staff/download/?pks=${query}`
    return http.downloadFile(path)
}

export default { 
    getAllDepartment,
    addsStaff,
    getStaffList,
    updateStaffStatus,
    downloadStaffs
}